package com.stevenmoon.csdnplus.activity.base;

import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.Toolbar;
import android.view.View;

import com.hannesdorfmann.mosby.mvp.MvpPresenter;
import com.hannesdorfmann.mosby.mvp.MvpView;
import com.mikepenz.iconics.IconicsDrawable;
import com.mikepenz.material_design_iconic_typeface_library.MaterialDesignIconic;
import com.stevenmoon.csdnplus.R;
import com.stevenmoon.csdnplus.widget.SwipeBackLayout;

/**
 * Created by WangJun on 2016/4/18.
 */
public abstract class MvpSwipeBaseActivity<V extends MvpView, P extends MvpPresenter<V>> extends MvpBaseActivity<V,P>{

    //@Bind(R.id.swipeBackLayout)
    SwipeBackLayout mSwipeBackLayout;

   // @Bind(R.id.toolbar)
    protected Toolbar mToolbar;


    protected  String getToolbarTitle(){return "请设置标题";}


    @Override
    protected void initViews() {
        mSwipeBackLayout = (SwipeBackLayout) findViewById(R.id.swipeBackLayout);
        initToolBar();
        mSwipeBackLayout.setCallBack(new SwipeBackLayout.CallBack() {
            @Override
            public void onFinish() {
                finish();
            }
        });
    }

    protected void initToolBar() {
        mToolbar = (Toolbar) findViewById(R.id.toolbar);
        if(mToolbar != null){
            mToolbar.setTitle(getToolbarTitle());
            setSupportActionBar(mToolbar);
            Drawable backDra = new IconicsDrawable(this)
                    //FIXME 主题相关
                    .color(Color.WHITE)
                    .icon(MaterialDesignIconic.Icon.gmi_arrow_back)
                    .sizeRes(R.dimen.nav_icon_size);
            mToolbar.setNavigationIcon(backDra);
            mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    onBackPressed();
                }
            });
        }


    }

}
